package cn.rongdao.jrkabao.util;

import com.github.promeg.pinyinhelper.Pinyin;

import cn.rongdao.jrkabao.bean.cashadvance.SelectBankCardBean;

/**
 * Created by jack on 2017/8/8
 */

public class SelectBankUtil {

    public static void getPinyinList(SelectBankCardBean contactsBean) {
        String indexStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuilder builderNamePiny = new StringBuilder();//NIHAO
        StringBuilder builderNameMatch = new StringBuilder();//NH
        String name = contactsBean.getBank_name();
        for (int i = 0; i < name.length(); i++) {
            StringBuilder builderNamePer = new StringBuilder();
            String namePer = name.charAt(i) + "";//名字的每个字
            for (int j = 0; j < namePer.length(); j++) {
                char character = namePer.charAt(j);
                String pinCh = Pinyin.toPinyin(character).toUpperCase();
                builderNamePer.append(pinCh);
                builderNameMatch.append(pinCh.charAt(0));
                builderNamePiny.append(pinCh);
            }
            contactsBean.getNamePinyinList().add(builderNamePer.toString());//单个名字集合
        }
        contactsBean.setNamePinYin(builderNamePiny.toString());
        contactsBean.setMatchPin(builderNameMatch.toString());
        String firstPinyin = contactsBean.getNamePinYin().charAt(0) + "";
        if (indexStr.contains(firstPinyin)) {
            contactsBean.setPinyinFirst(firstPinyin);
        } else {
            contactsBean.setPinyinFirst("#");
        }
    }
}
